home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-10 | 4.2 KB | 133 lines | [TEXT/MPS ] |
- #include <MacApp.h>
-
- #include "TLightGrayAdorner.h"
-
- //----------------------------------------------------------------------------------------
- // TLtGrayAdorner::Initialize:
- //----------------------------------------------------------------------------------------
- #pragma segment MAAdornerNonRes
- pascal void TLtGrayAdorner::Initialize()
- {
- inherited::Initialize();
- fLtGrayPat = nil;
- fWhitePat = nil;
- }
- //----------------------------------------------------------------------------------------
- // TLtGrayAdorner::Free:
- //----------------------------------------------------------------------------------------
- #pragma segment MAAdornerNonRes
- pascal void TLtGrayAdorner::Free()
- {
- if(fLtGrayPat)
- DisposPixPat(fLtGrayPat);
- fLtGrayPat = nil;
-
- if(fWhitePat)
- DisposPixPat(fWhitePat);
- fWhitePat = nil;
-
- }
- //----------------------------------------------------------------------------------------
- // TLtGrayAdorner::ILtGrayAdorner:
- //----------------------------------------------------------------------------------------
- #pragma segment MAAdornerNonRes
- pascal void TLtGrayAdorner::ILtGrayAdorner()
- {
- FailInfo fi;
- Boolean wasPerm;
-
- // Initialize with our made up ID 'LGAD' and Do not free on deletion
-
- this->IAdorner('LGAD', kDontFreeOnDeletion);
-
- // now we'll create our light gray pattern for future use
- // Note use of MacApp global "gRGBVeryLtGray"
-
- if (fi.Try()) {
- wasPerm = PermAllocation(TRUE); // Set perm. alloc. TRUE
- fLtGrayPat = NewPixPat(); // Get the handle we need
- FailMemError();
- MakeRGBPat(fLtGrayPat,gRGBVeryLtGray); // Create the Light Gray pattern
-
- CRGBColor white(65535, 65535, 65535);
- fWhitePat = NewPixPat();
- FailMemError();
- MakeRGBPat(fWhitePat,white);
-
- wasPerm = PermAllocation(wasPerm); // restore old state
- fi.Success();
- }
- else {
- if(fLtGrayPat)
- DisposPixPat(fLtGrayPat);
- fLtGrayPat = nil;
-
- if(fWhitePat)
- DisposPixPat(fWhitePat);
- fWhitePat = nil;
-
- fi.ReSignal();
- }
- }
- //----------------------------------------------------------------------------------------
- // TLtGrayAdorner::Draw:
- //----------------------------------------------------------------------------------------
- #pragma segment MAAdornerRes
- pascal void TLtGrayAdorner::Draw(TView* itsView, const VRect& area)
- {
- VRect itsAdornExtent,biggerArea;
- CRect ltGrayArea,adornArea;
-
- TWindow *myWindow = itsView->GetWindow();
- itsView->GetAdornExtent(itsAdornExtent);
- itsView->ViewToQDRect(itsAdornExtent, adornArea);
-
- if(myWindow->IsActive() || myWindow->fFloats) {
- if (!(area & itsAdornExtent).Empty()) // is there something to draw?
- {
- // First the light gray area - only draw what we have to draw here...
-
- itsView->ViewToQDRect(area, ltGrayArea);// convert to QD coord's
- FillCRect(ltGrayArea,fLtGrayPat);
-
- // Now the white border - draw this around the entire extent of the view
-
- PenPixPat(fWhitePat);
- PenSize(2,2);
- FrameRect(adornArea); // Basic rectangle
-
- // Now a special deal for the case where we overlap the ResizeIcon
- // If our superview is a window...
-
- // ASSUMPTION ALERT:
- // This code assumes that our view completely overlaps the
- // resize icon *AND* that the resize icon is a 16 x 16 square
-
- if((itsView->fSuperView != nil) && itsView->fSuperView->IsMemberClass(GetClassIDFromName("TWindow"))) {
- TWindow *theWindow = itsView->GetWindow();
- if (theWindow->fIsResizable) { // And if this window has resize icon
- VRect myExtent,hisExtent;
- itsView->GetExtent(myExtent);
- theWindow->GetExtent(hisExtent);
- hisExtent.top = hisExtent.bottom - 16; // just the resize icon area
- hisExtent.left = hisExtent.right - 16;
- itsView->LocalToSuperVRect(myExtent);
-
- if (!(myExtent & hisExtent).Empty()) { // AND we overlap it
- MoveTo(adornArea.left,adornArea.top);
- LineTo(adornArea.right-2,adornArea.top);
- LineTo(adornArea.right-2,adornArea.bottom-17);
- LineTo(adornArea.right-17,adornArea.bottom-17);
- LineTo(adornArea.right-17,adornArea.bottom-2);
- LineTo(adornArea.left,adornArea.bottom-2);
- LineTo(adornArea.left,adornArea.top);
- } // if we overlap the resize icon
- } // if there is a resize icon
- } // if the super view is a window
- } // if there is something to draw
- }
- else { // window is inactive
- FillCRect(adornArea,fWhitePat);
- }
- }
-